<template>
  <my-container>
    <!--查询-->
    <template #header>
      <el-form
        class="ad-form-query"
        :inline="true"
        :model="filter"
        @submit.native.prevent
      >
        <el-form-item>
          <el-input
            v-model="filter.name"
            placeholder="项目名"
            clearable
            @keyup.enter.native="getProjectList"
          >
            <template #prefix>
              <i class="el-input__icon el-icon-search" />
            </template>
          </el-input>
        </el-form-item>
        <el-form-item v-if="checkPermission(['api:project:project:getpage'])">
          <el-button
            icon="el-icon-search"
            type="primary"
            @click="getProjectList"
          >查询</el-button>
        </el-form-item>
        <el-form-item v-if="checkPermission(['api:project:project:add'])">
          <el-button
            icon="el-icon-reflesh"
            type="primary"
            @click="onAdd"
          >新增</el-button>
        </el-form-item>
        <!-- <el-form-item>
          <el-button
            icon="el-icon-plus"
            type="primary"
            @click="editModel"
          >模板</el-button>
        </el-form-item> -->
        <el-form-item>
          <el-button
            icon="el-icon-plus"
            type="primary"
            @click="editGantt"
          >甘特</el-button>
        </el-form-item>
      </el-form>
    </template>

    <vxe-grid
      ref="xGrid"
      border
      :radio-config="{highlight:true,labelField: 'name', trigger: 'row'}"
      resizable
      stripe
      show-overflow
      :highlight-current-row="true"
      auto-resize
      size="small"
      height="auto"
      :loading="listLoading"
      :seq-config="{startIndex: (tablePage.currentPage - 1) * tablePage.pageSize}"
      :pager-config="tablePage"
      :columns="tableColumn"
      :data="roles"
      @page-change="pageChange"
      @radio-change="radiochange"
    >
      <template v-slot:status_default="{ row}">
        <el-tag :type="row.status =='新建'?'':row.status =='执行中'?'warning':row.status =='已完成'?'success':'info' ">{{ row.status }}</el-tag>
      </template>
      <template v-slot:operate="{$index, row }">
        <vxe-button icon="fa fa-edit" title="编辑" circle @click="onEdit($index,row)" />
        <vxe-button icon="fa fa-trash" title="删除" circle @click="onDelete($index,row)" />
        <vxe-button v-if="row.status=='新建'" icon="fa fa-play" title="开启" circle @click="onStart($index,row)" />
      </template>
    </vxe-grid>

    <vxe-modal v-if="checkPermission(['api:project:project:add'])" v-model="addFormVisible" :loading="addProjectLoading" title="新增项目" width="500" height="265" resize>
      <vxe-form :data="addForm" :rules="addFormRules" title-align="right" title-width="100" @submit="onAddSubmit">
        <vxe-form-item title="名称" field="name" span="24" :item-render="{name: 'ElInput', attrs: {placeholder: '请输入项目名'}}" />
        <vxe-form-item title="模板" field="modelId" span="24" :item-render="{name: 'ElSelect', attrs: {placeholder: '请选择模板'}, options: modellist,props: { clearable: true, filterable: true }}" />
        <vxe-form-item title="备注" field="remark" span="24" :item-render="{name: 'ElInput',attrs: {placeholder: '请输入备注'}}" />
        <vxe-form-item align="right" span="24">
          <vxe-button type="reset">重置</vxe-button>
          <vxe-button type="submit" status="primary">提交</vxe-button>
        </vxe-form-item>
      </vxe-form>
    </vxe-modal>

    <vxe-modal v-if="checkPermission(['api:warehouse:xbctype:update'])" v-model="editFormVisible" title="编辑项目" width="600" height="580" resize>
      <vxe-form :data="editForm" :rules="editFormRules" title-align="right" title-width="120" @submit="onEditSubmit">
        <vxe-form-item title="名称" field="name" span="12" :item-render="{name: 'ElInput', attrs: {placeholder: '请输入项目名'}}" />
        <vxe-form-item title="模板" field="modelId" span="24" :item-render="{name: 'ElSelect', options: modellist,props: { clearable: true, filterable: true }}" />
        <vxe-form-item title="备注" field="remark" span="24" :item-render="{name: 'ElInput',attrs: {placeholder: '请输入备注'}}" />
        <vxe-form-item align="right" span="24">
          <vxe-button @click="editclose()">取消</vxe-button>
          <vxe-button type="submit" status="primary">提交</vxe-button>
        </vxe-form-item>
      </vxe-form>
    </vxe-modal>

    <vxe-modal
      id="gantt"
      v-model="ganttShow"
      resize
      remember
      fullscreen
      destroy-on-close
      storage
      transfer
    >
      <template v-slot:title>
        <span>项目甘特</span>
      </template>
      <template>
        <gantt :projectid="pid" />
      </template>
    </vxe-modal>

    <vxe-modal
      id="edit"
      v-model="modalShow"
      resize
      destroy-on-close
      remember
      fullscreen
      storage
      transfer
    >
      <template v-slot:title>
        <span>编辑项目: {{ modelName }}</span>
      </template>
      <template>
        <vxe-toolbar perfect>
          <template v-slot:buttons>
            <vxe-button icon="fa fa-plus" status="perfect" @click="onTaskAdd">新增</vxe-button>
            <vxe-button icon="fa fa-save" status="perfect" @click="saveProjectModel">保存</vxe-button>
            <vxe-button icon="fa fa-refresh" status="perfect" @click="onReflesh">刷新</vxe-button>
            <vxe-button icon="fa fa-caret-down" status="perfect" @click="$refs.xTreeGrid.setAllTreeExpand(true)">展开</vxe-button>
            <vxe-button icon="fa fa-caret-right " status="perfect" @click="$refs.xTreeGrid.clearTreeExpand()">收缩</vxe-button>
          </template>
        </vxe-toolbar>
        <vxe-table
          ref="xTreeGrid"
          border
          resizable
          :keep-source="true"
          show-overflow
          height="750"
          size="small"
          :loading="mloading"
          :edit-config="{
            trigger: 'click',
            mode: 'row',
            activeMethod: activeRowMethod
          }"
          :tree-config="{children: 'children' ,expandAll:true}"
          :radio-config="{labelField: 'name', highlight: true}"
          @edit-actived="editActivedEvent"
        >
          <vxe-table-column type="radio" title="阶段/任务" width="400" tree-node />
          <vxe-table-column field="parentId" title="计划开始" :visible="false" />
          <vxe-table-column field="planBeginDate" title="计划开始" :edit-render="{name: '$input', props: {type: 'date',disabled: editDisabled }}" />
          <vxe-table-column field="planEndDate" title="计划完成" :edit-render="{name: '$input', props: {type: 'date',disabled: editDisabled}}" />
          <vxe-table-column field="status" width="150" title="阶段状态">
            <template v-slot="{ row }">
              <el-tag v-if="row.status!=null" :type="row.status =='未就绪'?'info':row.status =='待处理'?'':row.status =='进行中'?'warning':row.status =='已完成'?'success':'' ">{{ row.status }}</el-tag>
            </template>
          </vxe-table-column>
          <vxe-table-column field="taskFlag" width="150" title="任务状态">
            <template v-slot="{ row }">
              <el-tag v-if="row.taskFlag!=null" :type="row.taskFlag =='未处理'?'info':row.taskFlag =='处理中'?'warning':row.taskFlag =='已完成'?'success':'' ">{{ row.taskFlag }}</el-tag>
            </template>
          </vxe-table-column>
          <vxe-table-column
            field="responName"
            width="150"
            title="负责人"
            :edit-render="{
              name: 'ElSelect',
              options: usrList,
              props: { clearable: true, filterable: true ,disabled: editDisabled}
            }"
          />
          <vxe-table-column field="remark" title="备注" :edit-render="{ name: '$input', props: {disabled: editDisabled} }" />
          <vxe-table-column title="操作" width="150" show-overflow>
            <template v-slot="{ row }">
              <vxe-button v-if="row.parentId!==0" type="text" icon="fa fa-trash-o" @click="removeEvent(row)" />
            </template>
          </vxe-table-column>
        </vxe-table>
      </template>
    </vxe-modal>

    <vxe-modal v-model="addTaskVisible" title="新增任务" width="25%" height="450" :loading="submitLoading" resize>
      <vxe-form :data="addTaskForm" :rules="addTaskRules" title-align="right" title-width="110" @submit="onTaskSubmit">
        <vxe-form-item title="所属阶段" field="parentId" span="24" :item-render="{name: 'ElSelect', options: plplist, events: { change: changeValue }}" />
        <vxe-form-item title="任务" field="taskId" span="24" :item-render="{name: 'ElSelect', options: taskList}" />
        <vxe-form-item title="计划开始时间" field="planBeginDate" span="20" :item-render="{name: '$input', props: { type: 'date', placeholder: '请选择计划开始日期' }}" />
        <vxe-form-item title="计划结束时间" field="planEndDate" span="20" :item-render="{name: '$input', props: { type: 'date', placeholder: '请选择计划结束日期' }}" />
        <vxe-form-item title="责任人" field="responId" span="24" :item-render="{name: 'ElSelect', options: usrList,props: { clearable: true, filterable: true }}" />
        <vxe-form-item title="描述" field="remark" span="24">
          <vxe-textarea v-model="addTaskForm.remark" placeholder="请输入描述" size="mini" />
        </vxe-form-item>
        <vxe-form-item align="right" span="24">
          <vxe-button type="reset">取消</vxe-button>
          <vxe-button type="submit" status="primary">提交</vxe-button>
        </vxe-form-item>
      </vxe-form>
    </vxe-modal>

    <vxe-modal v-model="editTaskVisible" title="编辑任务" width="25%" height="450" :loading="submitLoading" resize>
      <vxe-form :data="editTaskForm" :rules="editTaskRules" title-align="right" title-width="110" @submit="onEditTaskSubmit">
        <vxe-form-item title="所属阶段" field="parentId" span="24" :item-render="{name: 'ElSelect', props:{ disabled: true}, options: plplist, events: { change: changeValue }}" />
        <vxe-form-item title="任务" field="taskId" span="24" :item-render="{name: 'ElSelect', options: taskList}" />
        <vxe-form-item title="计划开始时间" field="planBeginDate" span="20" :item-render="{name: '$input', props: { type: 'date', placeholder: '请选择计划开始日期' }}" />
        <vxe-form-item title="计划结束时间" field="planEndDate" span="20" :item-render="{name: '$input', props: { type: 'date', placeholder: '请选择计划结束日期' }}" />
        <vxe-form-item title="责任人" field="responId" span="24" :item-render="{name: 'ElSelect', options: usrList,props: { clearable: true, filterable: true }}" />
        <vxe-form-item title="描述" field="remark" span="24">
          <vxe-textarea v-model="addTaskForm.remark" placeholder="请输入描述" size="mini" />
        </vxe-form-item>
        <vxe-form-item align="right" span="24">
          <vxe-button type="reset">取消</vxe-button>
          <vxe-button type="submit" status="primary">提交</vxe-button>
        </vxe-form-item>
      </vxe-form>
    </vxe-modal>

  </my-container>
</template>

<script>
import { formatTime } from '@/utils'
import {
  getProjectListPage, getProject, editProject, addProject, removeProject, getTaskList, initModule, getTaskItemList, addTaskItem, getTaskItem, editTaskItem, startProject
} from '@/api/project/project'
import { getUserList } from '@/api/admin/user'
import { getWlffdwList } from '@/api/admin/dictionary'
import MyContainer from '@/components/my-container'
import Gantt from '@/views/xsproject/gantt'

export default {
  name: 'Project',
  components: { MyContainer, Gantt },
  data() {
    return {
      filter: {
        name: ''
      },
      pid: 0,
      modalShow: false,
      modelName: '',
      roles: [],
      pager: {},
      listLoading: false,
      editDisabled: false,
      records: [], // 列表选中列
      mloading: false, // 模态窗口的加载
      addProjectLoading: false,
      addFormVisible: false, // 新增界面是否显示
      ganttShow: false, // 控制甘特图的显示
      tablePage: {
        total: 0,
        currentPage: 1,
        pageSize: 10
      },
      submitLoading: false,
      usrList: [],
      mtableColumn: [
        { type: 'seq', width: 60 },
        { field: 'stockInId', title: '入库id', visible: false },
        { field: 'addStorageBatchCode', title: '入库批次' },
        { field: 'wlCode', title: '物料号' },
        { field: 'wlms', title: '物料名称' },
        { field: 'wlgg', title: '物料规格' },
        { field: 'remark', title: '备注' }
      ],
      mtableData: [],
      addDialogFormVisible: false,
      editFormVisible: false, // 编辑界面是否显示
      editLoading: false,
      tableColumn: [
        { type: 'seq', width: 60 },
        { type: 'radio', field: 'name', title: '项目名', width: 250, slots: {
          // 使用渲染函数
          default: ({ row }, h) => {
            return [
              h('span', {
                style: {
                  color: '#409EFF'
                },
                on: {
                  click: () => this.editModel(row)
                }
              }, row.name)
            ]
          }
        }},
        // { field: 'name', title: '项目名' },
        { field: 'status', title: '状态', slots: {
        // 对应自定义插槽的名称
          default: 'status_default'
        }},
        { field: 'model', title: '模板' },
        { field: 'remark', title: '备注' }
      ],
      editFormRules: {
        name: [{ required: true, message: '请输入项目名', trigger: 'blur' }]
      },
      addTaskRules: {
        parentId: [{ required: true, message: '请选择阶段', trigger: 'blur' }],
        taskId: [{ required: true, message: '请选择任务', trigger: 'blur' }],
        planBeginDate: [{ required: true, message: '请填写预计开始束日期', trigger: 'blur' }],
        planEndDate: [{ required: true, message: '请填写预计结束日期', trigger: 'blur' }],
        responId: [{ required: true, message: '请选择责任人', trigger: 'blur' }]
      },
      editTaskRules: {
        parentId: [{ required: true, message: '请选择阶段', trigger: 'blur' }],
        taskId: [{ required: true, message: '请选择任务', trigger: 'blur' }],
        planBeginDate: [{ required: true, message: '请填写预计开始束日期', trigger: 'blur' }],
        planEndDate: [{ required: true, message: '请填写预计结束日期', trigger: 'blur' }],
        responId: [{ required: true, message: '请选择责任人', trigger: 'blur' }]
      },
      plplist: [],
      // 编辑界面数据
      editForm: {
        id: 0,
        name: '',
        remark: ''
      },
      editFormRef: null,
      addTaskForm: {
        parentId: null,
        taskId: null,
        projectId: null,
        planBeginDate: null,
        planEndDate: null,
        responId: null,
        remark: ''
      },
      editTaskForm: {
        id: null,
        parentId: null,
        taskId: null,
        projectId: null,
        planBeginDate: null,
        planEndDate: null,
        responId: null,
        remark: ''
      },
      modellist: [],
      taskList: [],
      addTaskVisible: false, // 新增界面是否显示
      editTaskVisible: false,
      addLoading: false,
      addFormRules: {
        name: [
          { required: true, message: '请输入项目名', trigger: 'blur' }
        ]
      },
      // 新增界面数据
      addForm: {
        name: '',
        remark: '',
        modelId: ''
      },
      addFormRef: null,
      deleteLoading: false
    }
  },
  mounted() {
    if (this.checkPermission(['api:warehouse:xbctype:update', 'api:warehouse:xbctype:softdelete'])) {
      this.tableColumn.push({ title: '操作', width: 200, slots: { default: 'operate' }})
    }
    this.getProjectList()
  },
  methods: {
    formatCreatedTime: function(row, column, time) {
      return formatTime(time, 'yyyy-MM-dd hh:mm')
    },
    async pageChange({ currentPage, pageSize }) {
      this.tablePage.currentPage = currentPage
      this.tablePage.pageSize = pageSize
      this.getProjectList()
    },
    editclose() {
      this.editFormVisible = false
    },
    // 获取物料类型列表
    async getProjectList() {
      const para = {
        currentPage: this.tablePage.currentPage,
        pageSize: this.tablePage.pageSize,
        filter: this.filter
      }
      this.listLoading = true
      const res = await getProjectListPage(para)
      this.listLoading = false

      if (!res?.success) {
        return
      }

      this.tablePage.total = res.data.total
      const data = res.data.list
      data.forEach(d => {
        d._loading = false
      })
      this.roles = data
    },
    // 显示编辑界面
    async onEdit(index, row) {
      const loading = this.$loading()
      const res = await getProject({ id: row.id })
      loading.close()
      if (res && res.success) {
        const data = res.data
        this.editForm = data
        this.editFormVisible = true
      }
    },
    closeEditForm() {
      this.$refs.editForm.resetFields()
    },
    // 显示新增界面
    async onAdd() {
      this.addFormVisible = true
      this.addProjectLoading = true
      if (this.modellist.length === 0) {
        await this.getWlffdwList('MODEL_MG')
      }
      this.addProjectLoading = false
    },
    async onTaskAdd() {
      this.addTaskVisible = true
      this.submitLoading = true
      this.addTaskForm = {
        parentId: null,
        taskId: null,
        planBeginDate: null,
        projectId: null,
        planEndDate: null,
        responId: null,
        remark: ''
      }
      var result = this.$refs.xGrid.getRadioRecord()
      if (result != null) {
        this.modelCode = result.modelCode
      }
      // console.log('sss', this.pid)
      if (this.plplist.length === 0) {
        await this.getWlffdwList(this.modelCode)
      }
      if (this.usrList.length === 0) {
        await this.getUserList()
      }
      this.submitLoading = false
    },
    async onReflesh() {
      var result = this.$refs.xGrid.getRadioRecord()
      if (result != null) {
        this.loadModeldata(result.id)
        // this.$refs.xTreeGrid.setAllTreeExpand(false)
      }
    },
    async getUserList() {
      const res = await getUserList()
      if (res && res.success) {
        this.usrList = res.data
      }
    },
    async getWlffdwList(id) {
      const res = await getWlffdwList({ dicCode: id })
      if (res && res.success) {
        if (id === this.modelCode) {
          this.plplist = res.data
        }
        if (id === 'MODEL_MG') {
          this.modellist = res.data
        }
      }
    },
    activeRowMethod({ row, rowIndex }) {
      return row.status === null && row.taskFlag === '未处理'
    },
    editActivedEvent({ rowIndex, row }) {
      this.editDisabled = row.status !== null || row.taskFlag !== '未处理'
    },
    async  loadModeldata(id) {
      this.mloading = true
      var rs = await getTaskList({ id: id })
      if (rs.data.length > 0) {
        this.mtableData = rs.data
        this.mloading = false
        // this.$refs.zk.$el.click()
        this.$refs.xTreeGrid.reloadData(this.mtableData)
      } else {
        this.$XModal.confirm('还未生成模板数据，确认生成么？').then(async(type) => {
          if (type === 'confirm') {
            await initModule({ id: id })
            var dt = await getTaskList({ id: id })
            this.mtableData = dt.data
            this.mloading = false
          } else {
            this.mloading = false
            this.modalShow = !this.modalShow
          }
        })
      }
    },
    async  editModel(row) {
      // var result = this.$refs.xGrid.getRadioRecord()
      if (row != null) {
        this.modalShow = !this.modalShow
        this.modelName = row.name
        if (this.usrList.length === 0) {
          await this.getUserList()
        }
        this.loadModeldata(row.id)
      } else {
        this.$message({
          message: '请选择项目',
          type: 'warning'
        })
      }
    },

    async saveProjectModel() {
      const {
        insertRecords,
        // eslint-disable-next-line no-unused-vars
        removeRecords,
        // eslint-disable-next-line no-unused-vars
        updateRecords
      } = this.$refs.xTreeGrid.getRecordset()
      console.log(updateRecords)
      if (updateRecords.length !== 0) {
        await editTaskItem(updateRecords)
        this.$message({
          message: this.$t('admin.addOk'),
          type: 'success'
        })
        // 刷新
        var result = this.$refs.xGrid.getRadioRecord()
        if (result != null) {
          this.loadModeldata(result.id)
        }
      } else {
        this.$XModal.message({ status: 'warning', message: '没有修改数据！' })
      }
    },
    editGantt() {
      var result = this.$refs.xGrid.getRadioRecord()
      if (result != null) {
        this.pid = result.id
        // console.log('sss', this.pid)
        this.ganttShow = !this.ganttShow
        // console.log('rs', result)
        // this.loadModeldata(result.id)
      } else {
        this.$message({
          message: '请选择项目',
          type: 'warning'
        })
      }
    },
    closeAddForm() {
      this.$refs.addForm.resetFields()
    },
    async changeValue() {
      if (this.addTaskVisible === true) {
        this.getTaskList(this.addTaskForm.parentId)
      }
    },
    // // 编辑
    // async editEvent(row) {
    //   const loading = this.$loading()
    //   var result = this.$refs.xGrid.getRadioRecord()
    //   if (result != null) {
    //     this.modelCode = result.modelCode
    //   }
    //   if (this.plplist.length === 0) {
    //     await this.getWlffdwList('PLP_MODEL')
    //   }
    //   if (this.usrList.length === 0) {
    //     await this.getUserList()
    //   }
    //   const res = await getTaskItem({ id: row.id })
    //   loading.close()
    //   if (res && res.success) {
    //     const data = res.data
    //     this.editTaskForm = data
    //     console.log('dd', this.editTaskForm)
    //     this.getEditTaskList(this.editTaskForm.parentId, this.editTaskForm.taskId)
    //     this.editTaskVisible = true
    //   }
    // },
    async getEditTaskList(id, taskid) {
      var rs = this.$refs.xGrid.getRadioRecord()
      const res = await getTaskItemList({ id: id, projectId: rs.id, taskId: taskid })
      if (res && res.success) {
        this.taskList = res.data
        this.addTaskForm.taskId = null
        // this.editForm.xbcLocationId = null
      }
    },
    async getTaskList(id) {
      var rs = this.$refs.xGrid.getRadioRecord()

      const res = await getTaskItemList({ id: id, projectId: rs.id })
      if (res && res.success) {
        this.taskList = res.data
        this.addTaskForm.taskId = null
        // this.editForm.xbcLocationId = null
      }
    },
    // 编辑验证
    editFormValidate: function() {
      let isValid = false
      this.$refs.editForm.validate(valid => {
        isValid = valid
      })
      return isValid
    },
    // 编辑
    async onEditSubmit() {
      this.editLoading = true
      const para = _.cloneDeep(this.editForm)

      const res = await editProject(para)
      this.editLoading = false

      if (!res?.success) {
        return
      }

      this.$message({
        message: this.$t('admin.updateOk'),
        type: 'success'
      })
      this.editFormVisible = false
      this.getProjectList()
    },
    // 新增验证
    addFormValidate: function() {
      let isValid = false
      this.$refs.addForm.validate(valid => {
        isValid = valid
      })
      return isValid
    },
    async onEditTaskSubmit() {
      this.submitLoading = true
      var result = this.$refs.xGrid.getRadioRecord()
      // console.log('rs', result)
      // this.editTaskForm.parentId = result.id
      const para = _.cloneDeep(this.editTaskForm)
      const res = await editTaskItem(para)
      this.submitLoading = false
      if (!res?.success) {
        return
      }
      this.$message({
        message: this.$t('admin.addOk'),
        type: 'success'
      })
      this.editTaskVisible = !this.editTaskVisible
      this.loadModeldata(result.id)
    },
    async onTaskSubmit() {
      this.submitLoading = true
      var result = this.$refs.xGrid.getRadioRecord()
      this.addTaskForm.projectId = result.id
      const para = _.cloneDeep(this.addTaskForm)
      const res = await addTaskItem(para)
      this.submitLoading = false
      if (!res?.success) {
        return
      }
      this.$message({
        message: this.$t('admin.addOk'),
        type: 'success'
      })
      this.addTaskVisible = !this.addTaskVisible
      this.loadModeldata(result.id)
    },
    // 新增
    async onAddSubmit() {
      this.addLoading = true
      const para = _.cloneDeep(this.addForm)
      const res = await addProject(para)
      this.addLoading = false

      if (!res?.success) {
        return
      }

      this.$message({
        message: this.$t('admin.addOk'),
        type: 'success'
      })
      this.addFormVisible = false
      this.getProjectList()
    },
    // 删除验证
    deleteValidate(row) {
      let isValid = true
      if (row && row.name === 'admin') {
        this.$message({
          message: row.description + '，禁止删除！',
          type: 'warning'
        })
        isValid = false
      }

      return isValid
    },
    // currentChange({ row }) {
    //   console.log('row', row)
    //   this.selectRow = row
    //   // this.$refs.xGrid.setRadioRow(row)
    // },
    // 删除
    async onDelete(index, row) {
      this.$XModal.confirm('您确定要删除该数据?').then(async(type) => {
        if (type === 'confirm') {
          row._loading = true
          const para = { id: row.id }
          const res = await removeProject(para)
          row._loading = false
          if (!res?.success) {
            return
          }
          this.$message({
            message: this.$t('admin.deleteOk'),
            type: 'success'
          })
          this.getProjectList()
        }
      })
    },
    // 项目启动
    async onStart(index, row) {
      this.$XModal.confirm('您确定要开启该项目?').then(async(type) => {
        if (type === 'confirm') {
          row._loading = true
          const para = { id: row.id }
          const res = await startProject(para)
          row._loading = false
          if (!res?.success) {
            return
          }
          this.$message({
            message: '启动成功',
            type: 'success'
          })
          this.getProjectList()
        }
      })
    },
    radiochange(row) {

      // this.records = event.records
    }
  }
}
</script>
